package com.lib.framework.base.mvvm

import android.app.Application
import android.os.Bundle
import com.lib.framework.entity.Event

/**
 * 基本 fragment 的 ViewModel
 *
 * @author keanbin
 */
abstract class BaseFragmentViewModel(application: Application) : BaseViewModel(application) {


    /**
     * 发送事件给 activity，activtiy 需要实现 SendEventToActivityListener 接口
     */
    protected fun sendEventToActivity(eventCode: Int) {
        sendEventToActivity(Event(eventCode))
    }

    /**
     * 发送事件给 activity
     */
    protected fun sendEventToActivity(event: Event) {
        sendEvent(BaseViewModelFragment.EVENT_SEND_TO_ACTIVITY, event)
    }

    /**
     * 从 arguments 初始化外部传入的数据
     */
    abstract fun initData(bundle: Bundle?)
}